<!DOCTYPE html>
<html>
<head>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<style>
		.login{
			    height: 200px;
			    width: 260px;
			    padding: 20px;
			    background-color: rgba(176,196,222,0.4);
			    border-radius: 4px;
			    position: absolute;
			    left: 78%;
			    top: 40%;
			    margin: -150px 0 0 -150px;
			    z-index: 99;
		}
	</style>
	<#include "/common/header.xhtml" >
</head>
<body>
	<div class="layui-row" style="padding-left: 15px;padding-top: 2px">
		<div class="layui-col-md4" style="float: left;">
			<img src="${contentPath}images/logo.png" width="150px" />
			<div style="display: inline;padding-left: 5px;font-size: 25px;text-align: center;vertical-align: middle;">测试</div>
		</div>
		<div class="layui-col-md8">
		</div>
	</div>
		<div class="layui-row" style="padding-top: 15px">
			<div class="layui-col-md12">
				<div class="layui-carousel" id="imgDiv">
					<div carousel-item="">
						<div><img src="${contentPath}/images/banner1.jpg" width="100%" height="750px"></div>
						<div><img src="${contentPath}/images/banner2.jpg" width="100%" height="750px"></div>
						<div><img src="${contentPath}/images/banner3.jpg" width="100%" height="750px"></div>
					</div>
				</div>
			</div>
	</div>
	<div class="layui-row">
		<div class="layui-col-md12" align="center" >
			<p style="color:#939393;">Copyright</p>
		</div>
	</div>
	<div class="login" >
		<h1 align="center">管理员登录</h1>
		<form class="layui-form" style="padding-top: 10px">
			<div class="layui-form-item" >
				<input class="layui-input" id="username" name="username" placeholder="用户名" value=""  type="text" autocomplete="off">
			</div>
			<div class="layui-form-item" >
				<input class="layui-input" id="password" name="password" placeholder="密码" value=""   type="password" autocomplete="off">
			</div>
			<button class="layui-btn"  style="width: 100%" lay-submit="" lay-filter="login">登录</button>
		</form>
	</div>
</body>
<script type="text/javascript">
layui.use(['carousel', 'form','layer'], function () {
	var carousel = layui.carousel
  	var form = layui.form;
	var layer = layui.layer;
	
	carousel.render({
		elem:"#imgDiv",
		interval:2000,
		arrow:"none",
		width:"100%",
		height:"550px"
	});
	
	form.on('submit(login)', function(formdata){
		if(formdata.field.username==null || $.trim(formdata.field.username)==''){
			layer.tips('用户名不能为空', '#username',{
				  tips: [1,'#FF0000']
			});
			return false;
		}
		if(formdata.field.password==null || $.trim(formdata.field.password)==''){
			layer.tips('密码不能为空', '#password',{
				  tips: [1,'#FF0000']
			});
			return false;
		}
		$.ajax({
            url: "${contentPath}/login",
            data: {
            	userName: $.trim(formdata.field.username),
                userPwd: $.trim(formdata.field.password)
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.ecode == 1000) {
                    window.location.href = '${contentPath}/main';
                } else {
                	layer.tips(data.massage, '#username',{
      				  tips: [1,'#FF0000']
      				});
                }
            }  
        });
		return false;
	});
	
});
</script>
</html>